<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>file_Add.jsp</title>
	<script type="text/javascript" src="./jquery-1.4.2.min.js"></script>
	<script type="text/javascript">
	// http://localhost:8080/WillThink/test/fileAddJsp.think
		var fileIndex = 0;
	
		function initFileForm() {
			addFileForm();
		}
	
		function addFileForm() {
			if (this.fileIndex > 0) {
				document.getElementById("file[" + (this.fileIndex - 1) + "]").style.display = "none";
			}
			var file = document.createElement("input");
			file.type = "file";
			file.id = "file[" + this.fileIndex + "]";
			file.name = "file[" + (this.fileIndex++) + "]";
			file.onchange = function() {
				addFileForm();
			};
			document.getElementById("fileForm").appendChild(file);
			drawFileList();
	
		}
	
		function removeFileForm(index) {
			var child = document.getElementById("file[" + index + "]");
			document.getElementById("fileForm").removeChild(child);
			drawFileList();
		}
	
		function drawFileList() {
			var html = "";
	
			var file;
			
			for ( var i = 0; i < this.fileIndex; i++) {
				file = document.getElementById("file[" + i + "]");
				if (file == null) {
					continue;
				}
	
				if (file.value.length == 0) {
					continue;
				}
	
				html += file.value + "&nbsp;<a href=\"javascript:removeFileForm(" + i + ");\">remove</a><br />";
			}
			document.getElementById("fileList").innerHTML = html;
		}
	</script>
</head>
<body onload="javascript:initFileForm();">

  <form action="./fileAdd.think" enctype="multipart/form-data" method="post">
  	<div id="fileForm"></div>
  	<div id="fileList"></div>
  	<input type="submit" value=" Upload " />
  </form>

 



</body>

</html>